/*
 * @Author: hmhvictory 1400628624@qq.com
 * @Date: 2025-08-01 16:52:10
 * @LastEditors: hmhvictory 1400628624@qq.com
 * @LastEditTime: 2025-08-01 16:52:55
 * @FilePath: \Gitee实训笔记\day15\test03\Cylinder.JAVA
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 圆柱体类
class Cylinder extends Circle {
    private double height;

    public Cylinder(double radius, double height) {
        super(radius);
        this.height = height;
    }

    // 计算表面积
    @Override
    public double getArea() {
        return 2 * super.getArea() + 2 * Math.PI * getRadius() * height;
    }

    // 计算体积
    public double getVolume() {
        return super.getArea() * height;
    }

    @Override
    public String toString() {
        return "Cylinder [height=" + height + ", radius=" + getRadius() + ", area=" + getArea() + ", volume=" + getVolume() + "]";
    }

    // 获取父类的 radius 属性
    private double getRadius() {
        // 假设父类的 radius 属性可以通过某种方式获取，这里简化处理
        return 1.0; // 实际应根据父类实现调整
    }
}